package com.oreilly.ez.web;

import com.oreilly.ez.base.R;
import com.oreilly.ez.entity.WalleCard;
import com.oreilly.ez.entity.WalleItem;
import com.oreilly.ez.entity.WalleTag;
import com.oreilly.ez.repo.WalleCardRepo;
import com.oreilly.ez.repo.WalleItemRepo;
import com.oreilly.ez.repo.WalleTagRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/walle-items")
@Validated
public class WalleItemCtrl extends BaseCtrl<WalleItem>{

    @Autowired
    private WalleItemRepo walleItemRepo;



    @Override
    public Object find(WalleItem walleItem, Pageable pageable) {

        List<WalleItem> walleItemList = walleItemRepo.findAll();

        return walleItemList;
    }

    @Override
    public Object findOne(Integer id) {
        return null;
    }

    @Override
    public Object save(@RequestBody @Valid WalleItem walleItem) {

        walleItemRepo.save(walleItem);
        return R.ok(walleItem);
    }

    @Override
    public Object delete(Integer id) {
        return null;
    }
}
